package com.wish.blessingroad.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @author dhc
 * @since 2019-02-18
 */
@Data
@Accessors(chain = true)
@TableName("user")
public class User extends Model<User> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 用户名称
     */
    @NotBlank(message = "姓名不能为空")
    @Length(max = 60, message = "姓名长度超出限制")
    private String name;


    /**
     * 手机号
     */
    @Length(max = 13, message = "手机号长度超出限制")
    private String phone;

    /**
     * 推荐人id(渠道)
     */
    private Integer recommendId;

    /**
     * 创建日期
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createDate = LocalDateTime.now();

    /**
     * 是否删除：0:正常；1:关闭
     */
    private Integer status=0;

    /**
     * openid,微信支付标志用户
     */
    private String openid;
    /**
     * 性别：0	未知
     * 1	男性
     * 2	女性
     */
    private int gender=0;
    /**
     * 头像
     */
    private String avatarUrl;
    /**
     * 省
     */
    private String province;
    /**
     * 城
     */
    private String city;

    public User() {
    }

    public User(@NotBlank(message = "姓名不能为空") @Length(max = 60, message = "姓名长度超出限制") String name,
            Integer recommendId, Integer status, String openid, int gender,
            String avatarUrl, String province, String city) {
        this.name = name;
        this.recommendId = recommendId;
        this.status = status;
        this.openid = openid;
        this.gender = gender;
        this.avatarUrl = avatarUrl;
        this.province = province;
        this.city = city;
    }

    /**
     * 指定主键
     */
    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
